#define _CRT_SECURE_NO_WARNINGS 1
#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
char a[20][20];

int main() {
	int t; cin >> t;
	while (t--) {
		for (int i = 1; i <= 8; i++) {
			for (int j = 1; j <= 8; j++) {
				cin >> a[i][j];
			}
		}
		for (int i = 1; i <= 8; i++) {
			for (int j = 1; j <= 8; j++) {
				if (a[i][j] >= 'a' && a[i][j] <= 'z') cout << a[i][j];
			}
		}
		cout << endl;
	}
	return 0;
}